<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/

/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\User::class, function (Faker\Generator $faker) {
    static $password;

    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'password' => $password ?: $password = bcrypt('secret'),
        'remember_token' => str_random(10),
    ];
});

/**
 * 填充文章类,定义文章类需要填充的数据
 */
$factory->define(App\Http\Models\Post::class, function (Faker\Generator $faker) {
    return [
        'title' => $faker->realText(10),
        'content' => $faker->realText(2000),
        'user_id' => \Illuminate\Support\Facades\Auth::id() ?: 1,
    ];
});

/**
 * 填充专题类,定义专题类需要填充的数据
 */
$factory->define(App\Http\Models\Topic::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->word,
    ];
});

/**
 * 定义管理员用户
 */
$factory->define(\App\Admin\Models\AdminUser::class, function (Faker\Generator $faker) {
    return [
        'name' => 'admin',
        'password' => bcrypt('admin'),
    ];
});
